function showUnreadNews() {
    $(document).ready(function() {
        // data_provinve
        $.ajax({
            url: '/map_data',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.province);
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('data_province'));
                var option = {
                    series: [
                        {
                            name: '数量',
                            type: 'map',
                            geoIndex: 0,
                            data: data.province,
                        },
                    ],
                    tooltip: {
                        formatter: function (params, ticket, callback) {
                        // 获取该省份的销售和利润数据
                        var counts = params.data.value;
                        // 拼接提示框信息
                        return  params.name +'<br />' + '数量:' + counts ;
                        }
                    },
                    visualMap: {
                        min: 0,
                        max: 253880,
                        left: 'left',
                        top: 'bottom',
                        text: ['高', '低'],//取值范围的文字
                        inRange: {
                            color: ['#fff200', '#ff8800']//取值范围的颜色
                        },
                        show: true,//图注
                        textStyle: {color: '#fff'},
                    },
                    geo: {
                        map: 'china',
                        roam: false,//不开启缩放和平移
                        zoom: 1.23,//视角缩放比例
                        label: {
                            normal: {
                                show: true,
                                fontSize: '15',
                                color: 'rgba(0,0,0,0.7)'
                            }
                        },
                        itemStyle: {
                            normal: {
                                borderColor: 'rgba(0, 0, 0, 0.2)'
                            },
                            emphasis: {
                                areaColor: '#00b2ff',//鼠标选择区域颜色
                                shadowOffsetX: 0,
                                shadowOffsetY: 0,
                                shadowBlur: 20,
                                borderWidth: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    },
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            }
        });

        // sales_month
        $.ajax({
            url: '/bar_data',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.month);
                console.log(data.max_prices);
                console.log(data.min_prices);
                // 基于准备好的dom，初始化echarts实例
                var myChart_bar = echarts.init(document.getElementById('data_month'));
                var option_bar = {
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['最高价', '最低价'],
                        textStyle: {color: '#fff'},
                      },
                    // toolbox: {
                    //     show: true,
                    //     feature: {
                    //         magicType: { show: true, type: ['line'] },
                    //     }
                    // },
                    calculable: true,
                    xAxis: [
                    {
                        type: 'category',
                        splitLine: {
                          show: false
                        },
                        data: data.month,
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff'}
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                    ],
                    yAxis: [
                    {
                        type: 'value',

                        splitLine: {
                          show: false
                        },
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff',},
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                    ],
                    series: [
                    {
                        name: '最高价',
                        type: 'line',
                        data: data.max_prices,
                        itemStyle: {
                            color: '#ff8800'
                        }
                    },
                    {
                        name: '最低价',
                        type: 'line',
                        data: data.min_prices,
                        itemStyle: {
                            color: '#fff200'
                        }
                    },
                    ],
                    grid:{ // 让图表占满容器
                        top:"6px",
                        left:"53px",
                        right:"0px",
                        bottom:"33px"
                    },
                };
                myChart_bar.setOption(option_bar);
            }
        });

        // data_sex
        $.ajax({
            url: '/sex_data',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.sex);
                var myChart = echarts.init(document.getElementById('data_sex'));
                var option;

                option = {
                    tooltip: {
                        trigger: 'item'
                      },
                  legend: {
                    orient: 'vertical',
                    left: 'left',
                    textStyle: {color: '#fff'},
                  },
                  series: [
                    {
                      type: 'pie',
                      radius: [0, '95%'],
                      data: data.sex,
                      emphasis: {
                        itemStyle: {
                          shadowBlur: 10,
                          shadowOffsetX: 0,
                          shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                      },
                    }
                  ]
                };
                myChart.setOption(option);
            }
        })

        // data_holiday
        $.ajax({
            url: '/holiday_data',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.holiday);
                console.log(data.prices_2019);
                console.log(data.prices_2020);
                // 基于准备好的dom，初始化echarts实例
                var myChart_bar = echarts.init(document.getElementById('data_holiday'));
                var option_bar = {
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['2019', '2020'],
                        textStyle: {color: '#fff'},
                      },
                    // toolbox: {
                    //     show: true,
                    //     feature: {
                    //         magicType: { show: true, type: ['line'] },
                    //     }
                    // },
                    calculable: true,
                    xAxis: [
                    {
                        type: 'category',
                        splitLine: {
                          show: false
                        },
                        data: data.holiday,
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff'}
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                    ],
                    yAxis: [
                    {
                        type: 'value',

                        splitLine: {
                          show: false
                        },
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff',},
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                    ],
                    series: [
                    {
                        name: '2019',
                        type: 'bar',
                        data: data.prices_2019,
                        itemStyle: {
                            color: '#ff8800'
                        }
                    },
                    {
                        name: '2020',
                        type: 'bar',
                        data: data.prices_2020,
                        itemStyle: {
                            color: '#fff200'
                        }
                    },
                    ],
                    grid:{ // 让图表占满容器
                        top:"6px",
                        left:"53px",
                        right:"0px",
                        bottom:"33px"
                    },
                };
                myChart_bar.setOption(option_bar);
            }
        });

        //data_boat_month
        $.ajax({
            url: '/boat_month',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.boats);
                var myChart = echarts.init(document.getElementById('data_boat_month'));
                var option;

                option = {
                  tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                      type: 'shadow'
                    }
                  },
                  legend: {
                      textStyle: {color: '#fff'},
                  },
                  grid:{ // 让图表占满容器
                        top:"6px",
                        left:"53px",
                        right:"0px",
                        bottom:"33px"
                    },
                  xAxis: [
                    {
                      type: 'category',
                      data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月','9月', '10月', '11月', '12月'],
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff'}
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                  ],
                  yAxis: [
                    {
                      type: 'value',
                        splitLine: {
                          show: false
                        },
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff',},
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                  ],
                  series: data.boats
                };
                myChart.setOption(option);
            }
        })

        // data_boat_year
        $.ajax({
            url: '/boat_year',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.boat_name);
                console.log(data.year_data);
                console.log(data.boat_data);
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('data_boat_year'));
                var option;

                option = {
                    legend: {
                        data: data.boat_name
                    },
                    tooltip: {
                        trigger: "item",
                      },
                    grid:{ // 让图表占满容器
                        top:"6px",
                        left:"53px",
                        right:"0px",
                        bottom:"33px"
                    },
                    radar: {
                        indicator: data.boat_data
                    },
                    series: [
                    {
                      name: 'Budget vs spending',
                      type: 'radar',
                      data: data.year_data
                    }
                    ]
                };
                myChart.setOption(option);
            }
        });

        // data_agent
        $.ajax({
            url: '/agent_data',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.agent_name);
                console.log(data.agent_data);
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('data_agent'));
                var option;

                option = {
                  tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                      type: 'shadow'
                    }
                  },
                  grid:{ // 让图表占满容器
                        top:"6px",
                        left:"53px",
                        right:"0px",
                        bottom:"33px"
                    },
                  xAxis: {
                    type: 'value',
                    boundaryGap: [0, 0.01],
                      splitLine: {
                          show: false
                        },
                      axisLabel: {
                            show: true,
                            textStyle: {color: '#fff'}
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                  },
                  yAxis: {
                    type: 'category',
                    data: data.agent_name,
                      splitLine: {
                          show: false
                        },
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff',},
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                  },
                  series: data.agent_data
                };
                myChart.setOption(option);
            }
        });

        // data_day
        $.ajax({
            url: '/day_data',
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            data: {},
            success: function (data) {
                console.log(data.day_time);
                console.log(data.day_data);
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('data_day'));
                var option;
                option = {
                  tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                      type: 'cross',
                      label: {
                        backgroundColor: '#6a7985'
                      }
                    }
                  },
                  grid:{ // 让图表占满容器
                        top:"6px",
                        left:"53px",
                        right:"0px",
                        bottom:"33px"
                    },
                  xAxis: [
                    {
                      type: 'category',
                      boundaryGap: false,
                      data: data.day_time,
                        splitLine: {
                          show: false
                        },
                      axisLabel: {
                            show: true,
                            textStyle: {color: '#fff'}
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                  ],
                  yAxis: [
                    {
                      type: 'value'
                    }
                  ],
                  series: [
                    {
                      type: 'line',
                      stack: 'Total',
                      label: {
                        show: true,
                        position: 'top'
                      },
                      areaStyle: {},
                      data: data.day_data,
                        splitLine: {
                          show: false
                        },
                        axisLabel: {
                            show: true,
                            textStyle: {color: '#fff',},
                        },
                        //坐标轴线的颜色以及宽度
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "#fff",
                                width: 1,
                                type: "solid"
                            },
                        },
                    }
                  ]
                };
                myChart.setOption(option);
            }
        });
    });
}
// 定义一个变量来存储定时器的ID
var intervalId;

// 开始轮询
function startPolling() {
    showUnreadNews(); // 立即请求一次数据
    intervalId = setInterval(showUnreadNews, 120000); // 每两分钟执行一次
}

// 停止轮询
function stopPolling() {
    clearInterval(intervalId);
}

// 开始轮询
startPolling();


// 停止轮询
// stopPolling();
